package StudyCode.summary.myfile;

import java.io.IOException;
import java.nio.file.FileSystem;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.util.Set;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class UsingPosixFilePermission {
	public static void main(String[] args) {
		FileSystem fileSystem = FileSystems.getDefault();
		Path directory = fileSystem.getPath("./newDirectoryWPermissions");
		try {
			Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---");
			FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms);
			Files.createDirectory(directory, attr);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
